﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Binding基础
{
    /// <summary>
    /// CollectionBinding.xaml 的交互逻辑
    /// </summary>
    public partial class CollectionBinding : Window
    {
        public CollectionBinding()
        {
            InitializeComponent();

            List<ssss> list = new List<ssss>()
            {
                new ssss() { Name = "1", ID = 11, Age = 111 },
                new ssss() { Name = "2", ID = 22, Age = 222 },
                new ssss() { Name = "3", ID = 33, Age = 333 }
            };


            this.LsStudent.ItemsSource = list;
            this.LsStudent.DisplayMemberPath = "Name";


            Binding binding = new Binding("SelectedItem.ID") { Source = this.LsStudent };
            this.textboxID.SetBinding(TextBox.TextProperty, binding);








        }
    }

    public class ssss
    {
        public string Name { get; set; }
        public int ID { get; set; }
        public int Age { get; set; }
    }
}
